var newpin = [{
		src: 'img/01_xp1.jpg',
		title: '魅蓝S6新品开销想好',
		miaoshu: '直降300元'
	},
	{
		src: 'img/01_xp2.jpg',
		title: '新Nokia6',
		miaoshu: '直降300元'
	},
	{
		src: 'img/01_xp3.jpg',
		title: '三星爆款',
		miaoshu: '返200元云卷'
	},
	{
		src: 'img/01_xp4.png',
		title: '三星爆款',
		miaoshu: '直降300元'
	},
	{
		src: 'img/01_xp5.png',
		title: '品质年货预售会场',
		miaoshu: '1分抵50'
	},
	{
		src: 'img/01_xp6.png',
		title: '直邮专场拔草更放心',
		miaoshu: '后套装629元'
	}
]

function newspin(arr, state) {
	for (var i = 0; i < arr.length; i++) {

		var str = $(`  <li>
                            <a href="javascript:;">
                                <div class="p-name1">${arr[i].title}</div>
                                <div class="p-desc1">${arr[i].miaoshu}</div>
                                <div class="p-img1"><img src="${arr[i].src}" alt=""></div>
                            </a>
                        </li>`);
		state.append(str)
	}
}
newspin(newpin, $("#newPING"));


var phb = [{
		src: 'img/01_phb1.jpg',
		title: '志高嵌入式电陶炉家用双头双灶镶嵌式电磁炉双眼光波炉特价正品 不挑锅可烧烤 三环猛火 嵌入式双灶',
		money: '¥488.00',
		ph: 1
	},
	{
		src: 'img/01_phb2.jpg',
		title: 'Galanz/格兰仕G8OF23CN3LN-Q6',
		money: '¥599.00',
		ph: 2
	},
	{
		src: 'img/01_xp3.jpg',
		title: 'Ordro/欧达Z20数码摄像机支持win10',
		money: '¥18999.00',
		ph: 3
	},
	{

		src: 'img/01_xp4.png',
		title: '苏泊尔火红点近无油烟不粘锅炒锅家',
		money: '¥189.00',
		ph: 4
	},
	{

		src: 'img/01_xp5.png',
		title: '艾依美儿个性北欧沙发组合小户型简约',
		money: '¥3999.00',
		ph: 5
	},
	{

		src: 'img/01_xp6.png',
		title: '北极绒记忆枕头枕芯单人慢回弹太空枕头',
		money: '¥29.90',
		ph: 6
	}
]


function phbs(arr, ststus) {
	for (var i = 0; i < arr.length; i++) {

		var str = $(` <div class="com-li">
                                <div class="p-img">
                                    <a href="javascript:;"><img src="${arr[i].src}"
                                            alt=""></a>
                                </div>
                                <div class="p-name">${arr[i].title}</div>
                                <div class="p-price">${arr[i].money}</div>
                                <div class="p-font">${arr[i].ph}</div>
                            </div>`);
		ststus.append(str)
	}
}
phbs(phb, $("#second-ul"))





var movef = [{
		tatle: '商创生鲜',
		miaoshu: '年货带回家满199减60',
		src: 'img/01_movemin1.png'
	},
	{
		tatle: '商创众筹',
		miaoshu: "商创众筹",
		src: 'img/01_movemin2.png'
	},
	{
		tatle: '智能生活',
		miaoshu: '爆款29.9元起',
		src: 'img/01_movemin3.png'
	},
	{
		tatle: '企业采购季',
		miaoshu: '生活电器最高减900元',
		src: 'img/01_movemin4.png'
	},
	{
		tatle: '二手优品',
		miaoshu: 'iPhone 7P 12期免息',
		src: 'img/01_movemin5.png'
	},
	{
		tatle: '领劵中心',
		miaoshu: '抢1000元电脑券',
		src: 'img/01_movemin6.png'
	}
]



function moveright(arr, status) {
	for (var i = 0; i < arr.length; i++) {

		var str = $(` <li class="item1">
                    <a href="javascript:;">
                        <span class="line n-line"></span>
                        <p class="name">${arr[i].tatle}</p>
                        <span class="line w-line"></span>
                        <p class="desc">${arr[i].miaoshu}</p>
                        <div class="img">
                            <img src="${arr[i].src}" alt="">
                        </div>
                    </a>
                </li>`);
		status.append(str)
	}
}
moveright(movef, $("#clearfix"))











var imgS1 = [{
		src: 'img/01_data_01_1.jpg'
	}, {
		src: 'img/01_data_01_2.jpg'
	}, {
		src: 'img/01_data_01_3.jpg'
	},
	{
		src: 'img/01_data_01_4.jpg'
	},
	{
		src: 'img/01_data_01_5.jpg'
	},
	{
		src: 'img/01_data_01_6.jpg'
	},
	{
		src: 'img/01_data_01_7.jpg'
	},
	{
		src: 'img/01_data_01_8.jpg'
	},
	{
		src: 'img/01_data_01_9.jpg'
	},
	{
		src: 'img/01_data_01_10.jpg'
	}
];
var img2 = [{
		src: 'img/01_data_01_11.jpg'
	},
	{
		src: 'img/01_data_01_12.jpg'
	},
	{
		src: 'img/01_data_01_13.jpg'
	},
	{
		src: 'img/01_data_01_14.jpg'
	}
]
var show = [{
		src: 'img/01_show1.jpg'
	},
	{
		src: 'img/01_show2.jpg'
	},
	{
		src: 'img/01_show3.jpg'
	},
	{
		src: 'img/01_show4.jpg'
	},
	{
		src: 'img/01_show5.jpg'
	}
];







function SHOW(arr, tata) {
	for (var i = 0; i < arr.length; i++) {

		var imgs = $(`  <div class="banner-img banner-active "><img src="${arr[i].src}" alt=" ">
                </div>`);
		tata.append(imgs)
	}
}
SHOW(show, $(".banner"));


var i = [{
		src: 'img/01_1.png'
	},
	{
		src: 'img/01_2.png'
	},
	{
		src: 'img/01_3.png'
	},
	{
		src: 'img/01_4.png'
	},
	{
		src: 'img/01_5.png'
	}
];

imgs(i, $(".stocking-item"));

function imgs(arr, taga) {
	for (var i = 0; i < arr.length; i++) {

		var imgs = $(`<a href='#'><img src='${arr[i].src}'></a>`);
		taga.append(imgs)
	}
}

imgs(imgS1, $(".joliexie-con-top"));
imgs(img2, $(".joliexie-con-list"));
// $(".joliexie-con-top").append(str);
// imgs1(imgS1,$(".joliexie-con-top"));

// 

var showData = [{
		src: 'img/01_showData_02_1.jpg',
		text: '合生元Razer雷蛇雨林狼蛛幻彩版Ornata Chroma机械式',
		price: '¥2640.00',
		oldprice: '¥7700.00'
	},
	{
		src: 'img/01_showData_02_2.jpg',
		text: '海富通基金Razer雷蛇炼狱蛙蛇精英版/2013/幻彩/守望先锋',
		price: '¥264.00',
		oldprice: '¥377.00'
	},
	{
		src: 'img/01_showData_02_3.jpg',
		text: '三星耳机静音机降噪,你值得拥有',
		price: '¥640.00',
		oldprice: '¥700.00'
	},
	{
		src: 'img/01_showData_02_4.jpg',
		text: '三星C24F396FH曲面显示器23.5英寸电脑显示器24液晶显示屏幕超22',
		price: '¥1299.00',
		oldprice: '¥2200.00'
	},
	{
		src: 'img/01_showData_02_5.jpg',
		text: '三星C24F396FH曲面显示器23.5英寸电脑显示器24液晶显示屏幕超22',
		price: '¥1299.00',
		oldprice: '¥3100.00'
	},
	{
		src: 'img/01_showData_02_6.jpg',
		text: '三星C24F396FH曲面显示器23.5英寸电脑显示器24液晶显示屏幕超22',
		price: '¥1300.00',
		oldprice: '¥2100.00'
	}, {
		src: 'img/01_showData_02_7.jpg',
		text: '三星C24F396FH曲面显示器23.5英寸电脑显示器24液晶显示屏幕超22',
		price: '¥1289.00',
		oldprice: '¥1790.00'
	}, {
		src: 'img/01_showData_02_8.jpg',
		text: '三星C24F396FH曲面显示器23.5英寸电脑显示器24液晶显示屏幕超22',
		price: '¥1499.00',
		oldprice: '¥1999.00'
	}, {
		src: 'img/01_showData_02_9.jpg',
		text: '三星C24F396FH曲面显示器23.5英寸电脑显示器24液晶显示屏幕超22',
		price: '¥1888.00',
		oldprice: '¥2018.00'
	}, {
		src: 'img/01_showData_02_10.jpg',
		text: '三星C24F396FH曲面显示器23.5英寸电脑显示器24液晶显示屏幕超22',
		price: '¥1220.00',
		oldprice: '¥1490.00'
	}
];

var haohuo = [{
		src: 'https://x.dscmall.cn/storage/data/gallery_album/61/original_img/1515953437766680336.jpg',
		pname: '360行车记录',
		miaoshu: '夜视 监控 电子狗 蓝牙'
	},
	{
		src: 'https://x.dscmall.cn/storage/data/gallery_album/61/original_img/1515953437822309342.jpg',
		pname: '攀升兄弟',
		miaoshu: '17独显主机'
	},
	{
		src: 'https://x.dscmall.cn/storage/data/gallery_album/61/original_img/1515953438203658169.jpg',
		pname: 'OPPO R11',
		miaoshu: '新品热力红 30天免息'
	},
	{
		src: 'https://x.dscmall.cn/storage/data/gallery_album/61/original_img/1515953438223405786.jpg',
		pname: '三星55寸',
		miaoshu: '4K处理器流畅不卡顿'
	},
	{
		src: 'https://x.dscmall.cn/storage/data/gallery_album/61/original_img/1515953438419443895.jpg',
		pname: '华为智能腕表',
		miaoshu: '防水蓝宝石玻璃面'
	},
	{
		src: 'https://x.dscmall.cn/storage/data/gallery_album/61/original_img/1515953438771578335.jpg',
		pname: '海尔对开门',
		miaoshu: '冷风无霜 低温 净味'
	}
]

function haohuos(arr, taga) {
	for (var i = 0; i < arr.length; i++) {
		var str = $(`<li class="sew-item">
                        <div class="p-img p-img-scale">
                            <a href="#"><img src="${arr[i].src}" alt=""></a>
                        </div>
                        <div class="p-info">
                            <div class="p-name">${arr[i].pname}</div>
                            <div class="p-desc">${arr[i].miaoshu}</div>
                        </div>
                    </li>`);
		taga.append(str);
	};
}
haohuos(haohuo, $("#hao"))


function showimgs(arr, target) {
	for (var i = 0; i < arr.length; i++) {
		var str = $(
			`<li><div class="item-img"><a href="#"><img src="${arr[i].src}" alt=""></a></div><div class="item-title"><a href="#">${arr[i].text}</a></div><div class="item-price"><span class="goods-price">${arr[i].price}</span><span class="original-price">${arr[i].oldprice}</span></div></li>`
		);
		target.append(str);
	};
};

showimgs(showData, $('#seckilllist'));
var indexData2 = [{
	src: 'img/01_data02_1.jpg',
	text: '摩飞(Morphyrichdares) 榨汁机',
	price: '¥219.00',
	oldprice: '¥399.00'
}, {
	src: 'img/01_data_02_2.jpg',
	text: '合生元Razer雷蛇 雨林狼蛛幻彩键盘',
	price: '¥233.00',
	oldprice: '¥279.00'
}, {
	src: 'img/01_data_02_3.jpg',
	text: '喜瑞新款学院风韩版时尚太空棉',
	price: '¥233.00',
	oldprice: '¥279.00'
}, {
	src: 'img/01_data_02_4.jpg',
	text: '华帝新款韩版chic学生宽松短款',
	price: '¥233.00',
	oldprice: '¥360.00'
}, {
	src: 'img/01_data_02_5.jpg',
	text: '鸿星尔克韩都衣舍2017韩版女',
	price: '¥450.00',
	oldprice: '¥540.00'
}, {
	src: 'img/01_data_02_6.jpg',
	text: '工银瑞信Samsung/三星Galax',
	price: '¥3233.00',
	oldprice: '¥4279.00'
}, {
	src: 'img/01_data_02_7.jpg',
	text: '迪士尼伊米妮2017春新款简约',
	price: '¥833.00',
	oldprice: '¥1279.00'
}, {
	src: 'img/01_data_02_8.jpg',
	text: '汤臣倍健春季马丁靴男真皮男靴',
	price: '¥633.00',
	oldprice: '¥1279.00'
}, {
	src: 'img/01_data_02_9.jpg',
	text: '匡威Apple/苹果Apple Watch',
	price: '¥3188.00',
	oldprice: '¥3025.00'
}, {
	src: 'img/01_data_02_10.jpg',
	text: '磨铁图书DIY台式电脑整机I7四',
	price: '¥1338.00',
	oldprice: '¥1665.00'
}, {
	src: 'img/01_data_02_11.jpg',
	text: '姬芮NewEra纽亦华新款MLB棒',
	price: '¥219.00',
	oldprice: '¥262.00'
}, {
	src: 'img/01_data_02_12.jpg',
	text: '康比特森马针织衫冬季男圆领',
	price: '¥80.00',
	oldprice: '¥96.00'
}, {
	src: 'img/01_data_02_13.jpg',
	text: '飞利浦TOSOT/大松GDF-2001',
	price: '¥388.00',
	oldprice: '¥465.00'
}, {
	src: 'img/01_data_02_14.jpg',
	text: '乔山洽福转椅轮子万向轮老板',
	price: '¥23.00',
	oldprice: '¥27.00'
}, {
	src: 'img/01_data_02_15.jpg',
	text: '猫人Xiaomi/小米小米电视4A',
	price: '¥2339.00',
	oldprice: '¥2679.00'
}, {
	src: 'img/01_data_02_16.jpg',
	text: '欧亚马山水F75.1家庭影院音响',
	price: '¥1233.00',
	oldprice: '¥2379.00'
}, {
	src: 'img/01_data_02_17.jpg',
	text: '小米空气净化器2S家用办公智能',
	price: '¥233.00',
	oldprice: '¥279.00'
}, {
	src: 'img/01_data_02_18.jpg',
	text: '小米8SE全面屏拍照游戏智能手机',
	price: '¥1888.00',
	oldprice: '¥2279.00'
}, {
	src: 'img/01_data_02_19.jpg',
	text: '小熊( Bear)咖啡机美式家用小功率',
	price: '¥129.00',
	oldprice: '¥279.00'
}, {
	src: 'img/01_data_02_21.jpg',
	text: '东菱Donlim多功能早餐机三',
	price: '¥399.00',
	oldprice: '¥569.00'
}, {
	src: 'img/01_data_02_21.jpg',
	text: '东菱Donlim多功能早餐机三',
	price: '¥399.00',
	oldprice: '¥569.00'
}];

function lodeindexData2(arr, target) {
	for (var i = 0; i < arr.length; i++) {
		var newLi = $(
			`<li class="xuanranli" data-shoucahng="${i+4}"><a href="pages/1232.html#${i+4}"><div class="p-img"><img src="${arr[i].src}" alt=""></div><div class="p-name">${arr[i].text}</div><div class="p-price clearfix"><div class="shop-price">${arr[i].price} </div><div class="original-price">${arr[i].oldprice}</div></div></a></li>`
		);
		target.append(newLi);
	}


};




lodeindexData2(indexData2, $('#plenty'));


$(".xuanranli").click(function() {
	localStorage.setItem("favorite" + $(this).attr("data-shoucahng"), $(this).attr("data-shoucahng"))
})




var navimg = [{
		src: 'img/01_nav_block_1.jpg'
	},
	{
		src: 'img/01_nav_block_2.jpg'
	},
	{
		src: 'img/01_nav_block_3.jpg'
	},
	{
		src: 'img/01_nav_block_4.jpg'
	},
	{
		src: 'img/01_nav_block_5.jpg'
	},
	{
		src: 'img/01_nav_block_6.jpg'
	},
	{
		src: 'img/01_nav_block_7.jpg'
	},
	{
		src: 'img/01_nav_block_8.jpg'
	},
	{
		src: 'img/01_nav_block_9.jpg'
	},
	{
		src: 'img/01_nav_block_10.jpg'
	}
]
//渲染二级导航的图片
function nav(arr, target) {
	for (var i = 0; i < arr.length; i++) {
		var str = $(` <img src="${arr[i].src}" alt="">`);
		target.append(str);
	}
}


nav(navimg, $(".small-img"));















































// js部分

$(function() {
	$("#guanbiguanggao").on('click', function() {
		$("#topggmax").animate({
			height: 0
		}, 400)
	})
})

$(function() {
	// //滚动navhover
	$('.hide-nav .goods-variety ').hover(function() {
			$('.hide-nav   .goods-variety ').find('.variety').show()
			$(".hide-nav .variety-item").hover(function() {
				$(this).css('background', 'rgba(0,0,0,0.5)').siblings(".hide-nav .variety-item")
					.css('background', 'rgba(51,51,51,0.8)')
				// console.log($('.publicity-img span'));
				$('.hide-nav #zzzzzz .cate-layer-con').eq($(this).index()).show().siblings(
					'.cate-layer-con').hide()
			}, function() {
				$('.hide-nav #zzzzzz .cate-layer-con').hover(function() {
					$(this).show()
				}, function() {
					$(this).hide()
				})
				$('.hide-nav .variety-item').css('background', 'rgba(51,51,51,.8)')
				$('.hide-nav #zzzzzz .cate-layer-con').hide()
			})
		},
		function() {
			$(".hide-nav .variety-item").hover(function() {
				$(this).css('background', 'rgba(0,0,0,0.5)').siblings(".hide-nav .variety-item")
					.css('background', 'rgba(51,51,51,0.8)')
				// console.log($('.publicity-img span'));
				$('.hide-nav #zzzzzz .cate-layer-con').eq($(this).index()).show().siblings(
					'.cate-layer-con').hide()
			}, function() {
				$('.hide-nav #zzzzzz .cate-layer-con').hover(function() {
					$(this).show()
				}, function() {
					$(this).hide()
				})
				$('.hide-nav .variety-item').css('background', 'rgba(51,51,51,0.8)')
				$('.hide-nav #zzzzzz .cate-layer-con').hide()
			})
			$('.hide-nav .goods-variety  .variety').hide()
		})
	// 头部hover部分显示与隐藏
	$(".navitems-wrap .variety-item").hover(function() {
		// console.log($('.publicity-img span'));
		$(this).css('background', 'rgba(0,0,0,0.5)').siblings(".navitems-wrap .variety-item").css(
			'background', 'rgba(51,51,51,0.8)')
		$('.navitems-wrap .cate-layer-con').eq($(this).index()).show().siblings('.cate-layer-con')
			.hide()
	}, function() {
		$(this).css('background', 'rgba(51,51,51,0.8)')
		$('.navitems-wrap .cate-layer-con').hover(function() {
			$(this).show()
		}, function() {
			$(this).hide()
		})
		$('.navitems-wrap .cate-layer-con').hide()
	})


	//banner淡入淡出轮播图
	var bannerindex = 0;
	$('.next').click(function() {
		bannerindex++
		if (bannerindex > $(".banner-img").length - 1) {
			bannerindex = 0
		}
		bannerchangeImg()

	})
	//自定义动画
	function bannerchangeImg() {
		$(".banner-img").eq(bannerindex).fadeIn(600).siblings(".banner-img").fadeOut(200)
		$('.banner-circle li').eq(bannerindex).addClass('circle-active').siblings('.banner-circle li')
			.removeClass('circle-active')
	}
	//自动轮播
	var bannerTimer = setInterval(function() {
		// clearInterval(bannerTimer)


		bannerindex++
		if (bannerindex > $(".banner-img").length - 1) {
			bannerindex = 0
			// console.log(bannerindex);

		}
		bannerchangeImg()


	}, 3000)
	//点击小圆点
	$('.banner-circle li').click(function() {
		bannerindex = $(this).index()
		bannerchangeImg()
	})
	// 鼠标移入关闭定时器
	$('.banner-img').hover(function() {
			clearInterval(bannerTimer)
		},
		function() {
			clearInterval(bannerTimer)

			bannerTimer = setInterval(function() {
				// $('.next').click()

				bannerindex++
				if (bannerindex > $(".banner-img").length - 1) {
					bannerindex = 0
				}
				bannerchangeImg()
			}, 3000)
		})


	//轮播定时器
	var seckilltimer

	// 轮播图
	//移入ul显示按钮
	$('.seckill-item').hover(function(e) {
		$('.seckill-item-wrap>div').show()
		clearInterval(seckilltimer)
	}, function() {
		$('.seckill-item-wrap>div').hide()
		seckilltimer = setInterval(function() {
			if (off) {
				off = false
				$('.seckill-item ').animate({
					left: oLeft
				}, 500, function() {
					$('.seckill-item ').find('li').slice(0, num).appendTo($(
						'.seckill-item'))
					$('.seckill-item ').css('left', 0)
					off = true
				})
			}
			// $('.seckill-previous').click()
		}, 2000)

	})

	//移入自身自身显示
	$('.seckill-item-wrap>div').hover(function() {
		$('.seckill-item-wrap>div').show()
	}, function() {
		$('.seckill-item-wrap>div').hide()
	})

	//给按钮绑定点击事件
	var off = true;
	var num = 1
	var oLeft = -num * $('.seckill-item li:first').outerWidth(true) + 'px';
	//下一个
	$('.seckill-previous').on('click', function() {
		if (off) {
			off = false
			$('.seckill-item ').animate({
				left: oLeft
			}, 500, function() {
				$('.seckill-item ').find('li').slice(0, num).appendTo($('.seckill-item'))
				$('.seckill-item ').css('left', 0)
				off = true
			})
		}
	})

	//上一个
	$('.seckill-next').on('click', function() {
		if (off) {
			off = false
			var olastli = $('.seckill-item').find('li').slice($('.seckill-item li').length - num)
			olastli.prependTo($('.seckill-item'))
			$('.seckill-item').css('left', oLeft)
			$('.seckill-item').animate({
				left: 0,
			}, 500, function() {
				off = true
			})
		}
	})
	//自动轮播
	seckilltimer = setInterval(function() {
		if (off) {
			off = false
			$('.seckill-item ').animate({
				left: oLeft
			}, 500, function() {
				$('.seckill-item ').find('li').slice(0, num).appendTo($('.seckill-item'))
				$('.seckill-item ').css('left', 0)
				off = true
			})
		}
		// $('.seckill-previous').click()
	}, 3000)

	//鼠标移入定时器结束






	// 侧边跳楼
	//绑定滚动事件
	$(window).scroll(function() {
		//显示滚动导航栏
		var oSrcolltop = $(window).scrollTop()

		if (oSrcolltop > $('.header').offset().top + 126) {
			$('.hide-nav').show()
		} else {
			$('.hide-nav').hide()
		}
		// 显示侧边栏
		if (oSrcolltop > $('.view').offset().top + $('.view').height()) {
			$('.yl-nav').show()
		} else {
			$('.yl-nav').hide()
		}
		//滚动跟随
		$('.main>div').each(function(index) {

			if (oSrcolltop > $(this).offset().top - 200) {
				$('.yl-nav>div').eq(index).addClass('yl-active').siblings('div').removeClass(
					'yl-active')
				$('.lift-item i').hide()
				$('.lift-item i').eq(index).show()

			}
		})


	})
	//点击
	// console.log($('.lift-item i'));
	$('.lift-item ').click(function() {
		// console.log($(this).index());
		var oH = $('.main>div').eq($(this).index()).offset().top - 100;
		$('body,html').animate({
			'scrollTop': oH
		}, 500)
		// console.log(111);

	})
	// 返回顶部
	$('.lift-top').click(function() {
		$('body,html').animate({
			'scrollTop': 0
		}, 500)
	})


	// 公告teb切换
	$('.vip-item-t span').hover(function() {
		$(this).addClass('fred').siblings('span').removeClass('fred')
		$('.vip-item-con').eq($(this).index()).addClass('vipblock').siblings('.vip-item-con')
			.removeClass('vipblock')
	});
	// 图片原始的top值
	var oldtop = 0;

	// console.log(oldtop1);
	// 给地图导航添加事件
	$('.dsc-choie').hover(function() {
		$(this).addClass('choie-active')
		$('.head-map').show()
		mapanimate()
	}, function() {
		$(this).removeClass('choie-active')
		$('.head-map').hide()
		$('.map-con-scrool').css('top', '64px')
		$('.map-con-warp1').css('top', '0px')
		$('.head-map').off('mousemove')
	})

	// 地图导航动画
	function mapanimate() {
		oldtop = $('.map-con-scrool').position().top;
		// var oldtop = oldtop1;
		// console.log(oldtop);
		$('.map-nav a').hover(function() {
			// 每个元素距离顶部的距离
			var scrolltopitem = $('.map-con-warp .map-con-itemr').eq($(this).index()).position().top;
			$('.map-con-warp1').css('top', -scrolltopitem + 'px')
			//图片移动的距离
			var scrolltopimg = $('.map-con-warp').height() / $('.map-con-warp1').height() *
				scrolltopitem
			var newscrolltopimg = oldtop + scrolltopimg + 'px';
			// console.log($('.map-con-warp').height() / $('.map-con-warp1').height());
			$('.map-con-scrool').css('top', newscrolltopimg)
		})

	}


})
























$('.screen-side-con li>a').hover(function() {
	$(this).addClass('current');
	$(this).find('.cart_num').addClass('color_change');
	$(this).find('.mp_tooltip').css({
		'visibility': 'visible'
	}).stop().animate({
		left: -92
	}, 300);
}, function() {
	$(this).removeClass('current');
	$(this).find('.cart_num').removeClass('color_change');
	$(this).find('.mp_tooltip').css({
		'visibility': 'hidden'
	}).stop().animate({
		left: -121
	}, 100)
})
$('.cart_list').click(function() {
	$('.screen-side-lay').toggleClass('show');
	if (!$(this).find('.cart_num').attr('style')) {
		$(this).find('.cart_num').css({
			'background': '#fff',
			'color': '#f42424'
		})
	} else {
		$(this).find('.cart_num').attr('style', '');
	}
	if ($(this).attr('style')) {
		$(this).attr('style', '');
	} else {
		$(this).css('background', '#f42424');
	}
})
$('.setting_hover').hover(function() {
	$('.setting-con').css('display', 'block');
}, function() {
	$('.setting-con').css('display', 'none');
})
$('.setting-con').hover(function() {
	$(this).css('display', 'block');
}, function() {
	$(this).css('display', 'none');
})
$('.login_btnbox').find('a').hover(function() {
	$(this).css('border', '1px solid #f00');
}, function() {
	$(this).css('border', '1px solid transparent');
})
$(document).ready(function() {
	$(window).scroll(function() {
		if ($(window).scrollTop() > 0) {
			$('.return_top_hover').css('display', 'block');
		} else {
			$('.return_top_hover').css('display', 'none');
		}
	})
	$(".return_top_sport").click(function() {
		$('body,html').animate({
				scrollTop: 0
			},
			500);
		$('.return_top_hover').css('display', 'none');
		return false;
	});
	if (Number($('.cart_list').find('.cart_num').text()) != 0) {
		$('.ecs-tbar-tipbox2').css('display', 'none');
	} else {
		$('.ecs-tbar-tipbox2').css('display', 'block');
	}
})
$('.side-car-title').find('.close').click(function() {
	$('.screen-side-lay').toggleClass('show');
	if (!$('.cart_list').find('.cart_num').attr('style')) {
		$('.cart_list').find('.cart_num').css({
			'background': '#fff',
			'color': '#f42424'
		})
	} else {
		$('.cart_list').find('.cart_num').attr('style', '');
	}
	if ($('.cart_list').attr('style')) {
		$('.cart_list').attr('style', '');
	} else {
		$('.cart_list').css('background', '#f42424');
	}
})
$('.email_hover').click(function() {
	$('.email_box').toggleClass('email_box_show');
})

$(document).on("mousewheel DOMMouseScroll", function(e) {
	// jq 获取dom 事件对象要通过originalEvent 
	var delta = (e.originalEvent.wheelDelta && (e.originalEvent.wheelDelta > 0 ? 1 : -1)) ||
		// chrome & ie
		(e.originalEvent.detail && (e.originalEvent.detail > 0 ? -1 : 1)); // firefox
	if (delta > 0) {
		// 向上滚
		$('.email_box').removeClass('email_box_show');
	}


});













// 侧栏购物车
for (var i = 0; i < localStorage.length; i++) {
	var key = localStorage.key(i);
	// console.log(key);
	if (key.includes('d')) {
		// console.log(key);
		var loca = localStorage.getItem(key);
		var arr = indexjson[loca].goodsList;
		// console.log(loca);
		var strGwc = "";
		arr.forEach(function(v, i) {
			// console.log(v.gname);
			strGwc += `
		<li class="sp-max">
			<div class="commodity-left">
				<a href="">
					<img src="${v.Commodityurl}"
						alt="">
				</a>
			</div>
			<div class="commodity-right">
				<a href=""
					class="commodity-right-a">${v.gname}</a>
				<div class="commodity-right-top">
					<span class="commodity-span">${v.newprice}</span>
					<div class="commodity-sc">
						<a href="javascript:void(0)" class="sp-dele" dele-id="${key}">删除</a>
					</div>
				</div>
				<div class="commodity-right-conter">
					<a href="javascript:void(0)" class="commodity-a"data-price="${v.newprice}"><i
							class="bi bi-dash-square" ></i></a>
					<span class="span-num"  >1</span>
					<a href="javascript:void(0)" class="commodity-a1" data-price="${v.newprice}"><i
							class="bi bi-plus-square"></i></a>
				</div>
			</div>
		</li>
		`;
			$('.commodity-son').append(strGwc);
		})
	}
}


// 购物车商品总数量
function gwcnums() {
	var span_nums = 0;
	var slzongjia = 0;
	$('.span-num').each(function(v, i) {
		span_nums += Number($(i).html());
	})
	$('.cart_num').html(span_nums);
	$('.side-spj').html(span_nums);
	$('.etgb').html(span_nums);
	$('.merchandise-left-span1').html(span_nums).css('color', 'red');
	$('.commodity-span').each(function(v, i) {
		slzongjia += Number($(i).html().substr(1));
	})
	$('.com_price b').html(slzongjia + '.00');
	$('.merchandise-left-span2').html(slzongjia + '.00');
}
gwcnums();
// 数量之和赋值给总数


// 减

$('.commodity-a').click(function() {
	var jiannum = $(this).next().html();
	if (jiannum <= 1) {
		return false;
	}
	jiannum--;
	$(this).next().text(jiannum);
	var comds = $(this).attr('data-price');
	var comdi1 = Number(comds.substr(1));
	var comds1 = jiannum * comdi1;
	// console.log(comds.substr(1), comds1);
	$(this).parents('.sp-max').children().find('.commodity-span').html('¥' + comds1 + '.00');
	gwcnums();
		var comind1 = $('.commodity-a').index($(this));
	var daDe = $(this).siblings('.span-num').html();
	// console.log(xiaoDe);
	$('.merchandise-jian').eq(comind1).parents('.merchandise-ul-number').children('.merchandise-span').html(daDe);
	var xiaoDejiage = $(this).parents('.commodity-right').find('.commodity-span').html();
	// console.log(xiaoDejiage);
	$('.merchandise-jian').eq(comind1).parents('.sp-max').find('.merchandise-ul-p').html(xiaoDejiage);

})
// 加
var jia_num = 1;
$('.commodity-a1').click(function() {
	jia_num = Number($(this).prev().text());
	jia_num++;
	$(this).prev().text(jia_num);
	// gwcnums();
	// $('.cart_num').html(span_nums);
	//总价
	var comds = $(this).attr('data-price');
	var comdi = Number(comds.substr(1));
	var comds1 = jia_num * comdi;
	$(this).parents('.sp-max').children().find('.commodity-span').html('¥' + comds1 + '.00');
	gwcnums();
	var comind = $('.commodity-a1').index($(this));
	console.log(comind);
	var daDe = $(this).siblings('.span-num').html();
	$('.merchandise-jia').eq(comind).parents('.merchandise-ul-number').children('.merchandise-span').html(daDe);
	var xiaoDejiage = $(this).parents('.commodity-right').find('.commodity-span').html();
	// console.log(xiaoDejiage);
	$('.merchandise-jia').eq(comind).parents('.sp-max').find('.merchandise-ul-p').html(xiaoDejiage);
})

$(".sp-dele").click(function() {
	$(this).parents('.sp-max').remove();
	var deleid = $(this)[0].getAttribute('dele-id');
	localStorage.removeItem(deleid);
	gwcnums();
	gwcnums1();

	// 购物车隐藏显示
	if ($('.cart_num').html() == 0) {
		$('.commodity').hide();
		$('.ecs-tbar-tipbox2').show();
	} else {
		$('.commodity').show();
	}

})


//我的购物车

for (var i = 0; i < localStorage.length; i++) {
	var key = localStorage.key(i);
	// console.log(key);
	if (key.includes('d')) {
		// console.log(key);
		var loca = localStorage.getItem(key);
		var arr = indexjson[loca].goodsList;
		var strGwc1 = "";
		arr.forEach(function(v, i) {
			// console.log(v, i);
			strGwc1 += `
		<li class="sp-max">
			<div class="merchandise-ul-img">
				<a href="javascript:void(0)">
					<img src="${v.Commodityurl}"
						alt="">
				</a>
			</div>
			<div class="merchandise-ul-name">
				<a href="javascript:void(0)">${v.gname}</a>
			</div>
			<div class="merchandise-ul-number">
				<span class="merchandise-span">1</span>
				<div class="merchandise-ul-number-div">
					<a href="javascript:void(0)" class="merchandise-jia" data-price='${v.newprice}'>&#xe76e;</a>
					<a href="javascript:void(0)" class="merchandise-jian" data-price='${v.newprice}'>&#xe772;</a>
				</div>
			</div>
			<div class="merchandise-ul-oper">
				<p class="merchandise-ul-p">${v.newprice}</p>
				<a href="javascript:void(0)" class='sp-dele' dele-id='${key}'>删除</a>
			</div>
		</li>
		`;
			$('.merchandise-ul').append(strGwc1);
		})
	}
}



// 购物车商品总数量
// 购物车商品总数量
function gwcnums1() {
	var merchandise_span = 0;
	var merchandise_ul_p = 0;
	$('.merchandise-span').each(function(v, i) {
		merchandise_span += Number($(i).html());
	})
	$('.cart_num').html(merchandise_span);
	$('.side-spj').html(merchandise_span);
	$('.etgb').html(merchandise_span);
	$('.merchandise-left-span1').html(merchandise_span);
	$('.merchandise-ul-p').each(function(v, i) {
		// console.log(v, i);
		merchandise_ul_p += Number($(i).html().substr(1));

	})
	$('.com_price b').html(merchandise_ul_p + '.00');
	$('.merchandise-left-span2').html(merchandise_ul_p + '.00');
}
// gwcnums1();



// // 数量之和赋值给总数


// // 减

$('.merchandise-jian').click(function() {
	var jiannum = $(this).parent().prev().html();
	if (jiannum <= 1) {
		return false;
	}
	jiannum--;
	$(this).parent().prev().html(jiannum);
	var comds = $(this).attr('data-price');
	var comdi1 = Number(comds.substr(1));
	var comds1 = jiannum * comdi1;
	// console.log(comds.substr(1), comds1);
	$(this).parents('.merchandise-ul-number').next().children('.merchandise-ul-p').html('¥' + comds1 + '.00');
	gwcnums1()
	var jianind = $('.merchandise-jian').index($(this));
	var xiaoDe = $(this).parents('.merchandise-ul-number').children('.merchandise-span').html();
	// console.log(xiaoDe);
	$('.commodity-a').siblings('.span-num').eq(jianind).html(xiaoDe);
	var xiaoDejiage = $(this).parents('.merchandise-ul-number').siblings('.merchandise-ul-oper').children(
		'.merchandise-ul-p').html();
	// console.log(xiaoDejiage);
	$('.commodity-a').parents('.commodity-right').find('.commodity-span').eq(jianind).html(xiaoDejiage);

// 111

})
// 加
var jia_num1 = 1;
$('.merchandise-jia').click(function() {
	jia_num1 = Number($(this).parent().prev().text());
	jia_num1++;
	$(this).parent().prev().text(jia_num1);
	//总价
	var comds = $(this).attr('data-price');
	var comdi = Number(comds.substr(1));
	var comds1 = jia_num1 * comdi;
	$(this).parents('.merchandise-ul-number').next().children('.merchandise-ul-p').html('¥' + comds1 + '.00');
	gwcnums1()
	var jiaind = $('.merchandise-jia').index($(this));
	// console.log(jiaind);
	var xiaoDe = $(this).parents('.merchandise-ul-number').children('.merchandise-span').html();
	$('.commodity-a1').siblings('.span-num').eq(jiaind).html(xiaoDe);
	// console.log(xiaoDe);
	var xiaoDejiage = $(this).parents('.merchandise-ul-number').siblings('.merchandise-ul-oper').children(
		'.merchandise-ul-p').html();
	// console.log(xiaoDejiage);
	$('.commodity-a1').parents('.commodity-right').find('.commodity-span').eq(jiaind).html(xiaoDejiage);


})


function dian() {
	$(".sp-dele").click(function() {
		// window.location.assign();
		location.reload(true);
		$(this).parents('.sp-max').remove();
		var deleid = $(this)[0].getAttribute('dele-id');
		// console.log(deleid);
		localStorage.removeItem(deleid);
		gwcnums1();
		gwcnums();
		var inde = $('.sp-max').index($(this));
		console.log(inde);
	})

	// 	// 购物车隐藏显示
	if ($('.cart_num').html() == 0) {
		$('.yc').show();
		// $('.merchandise-ul').hide();
	} else {
		// $('.merchandise-ul').show();
		$('.yc').hide();

	}

}
dian();
